package org.grottarossa.ui.core.base;


import java.util.Hashtable;

import org.grottarossa.ui.core.ApplicationSession;
import org.grottarossa.ui.core.CommonResources;
import org.grottarossa.ui.core.FormFieldLocation;
import org.grottarossa.ui.core.Notifier;

import com.vaadin.data.Buffered;
import com.vaadin.data.Validator.EmptyValueException;
import com.vaadin.data.Validator.InvalidValueException;
import com.vaadin.ui.Form;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Window.Notification;

/***
 * Classe generica dalla quale devono ereditare tutte le form che svolgono il ruolo di View in un pattern MVP
 * @author 
 *
 * @param <T>
 */
public abstract class BaseFormView<T> extends BaseForm
{
	/*** Gestisce la logica della view ***/
	protected T m_presenter;

	public BaseFormView(ApplicationSession appSession)
	{
		super(appSession);
	}

	/***
	 * Imposta il presenter della classe
	 * @param presenter
	 */
	public void setPresenter(T presenter)
	{
		m_presenter = presenter;
	}

	@Override
	public void commit() throws Buffered.SourceException, InvalidValueException
    {
		 try
		 {
			 super.commit();
		 }
		 catch(EmptyValueException ex)
		 {
			 showWarning(CommonResources.getCommonMessagesRB().getString("message.warning.emptyfield"));
			 throw ex;
		 }
		 catch(InvalidValueException ex)
		 {
			 showWarning(CommonResources.getCommonMessagesRB().getString("message.warning.invalidfield"));
			 throw ex;
		 }
    }
}
